/*https://leetcode.cn/problems/house-robber/submissions/546066728/*/
class Solution {
public:
    int rob(vector<int>& nums) {
        int n = nums.size();
        int dp[n][2];
        dp[0][0] = 0;
        dp[0][1] = nums[0];
        for(int i = 1;i < n;i++){
            dp[i][0] = max(dp[i-1][0],dp[i-1][1]);//如果这家没被偷，上一家偷不偷都行，开始想错，想成这家没被偷，上一家肯定会被偷
            dp[i][1] = dp[i-1][0] + nums[i];
        }
        return max(dp[n-1][0],dp[n-1][1]);
    }
};